n = int(input())
h = list(map(int, input().split()))
dp = [dict() for _ in range(n)]  # dp[i][j]以i为结尾间距为k的最长递增子序列
max_length = 0
for i in range(n):
    for j in range(i - 1, -1, -1):
        if h[i] > h[j]:
            dp[i][i - j] = max(dp[i].get(i - j, 1), dp[j].get(i - j, 1) + 1)
            max_length = max(max_length, dp[i][i - j])
            break
print(max_length)
